﻿// VaultClient.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>
#include "gflags/gflags.h"
#include "Client.h"

DEFINE_string(configFile, "./config/client.xml", "client config file");
DEFINE_string(importData, "./config/importData.xml", "import data config file");
DEFINE_string(search, "", "search config file");
DEFINE_string(syncData, "", "sync data config file");

int main(int argc, char **argv)
{
	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
	DWORD mode;
	GetConsoleMode(hStdin, &mode);
	mode &= ~ENABLE_QUICK_EDIT_MODE;  //移除快速编辑模式
	mode &= ~ENABLE_INSERT_MODE;      //移除插入模式
	mode &= ~ENABLE_MOUSE_INPUT;
	SetConsoleMode(hStdin, mode);

	google::InitGoogleLogging(argv[0]);
	google::SetLogDestination(ERROR, "log/client_");
	google::SetStderrLogging(google::GLOG_INFO);

    gflags::SetVersionString("0.0.0.1");
    gflags::SetUsageMessage("Please enter host, port");
    google::ParseCommandLineFlags(&argc, &argv, true);

    Client client(FLAGS_configFile);

	if (FLAGS_search.empty() == false)
	{
		client.search(FLAGS_search);
	}
	else if (FLAGS_syncData.empty() == false)
	{
		client.syncCmd(FLAGS_syncData);
	}
	else
	{
		client.importData(FLAGS_importData);
	}
}
